const path = require('path');
const fs = require('fs');

// 测试路径
const testPaths = [
    '/other-dir/file.js',
    path.join(process.cwd(), 'www/node_modules/lodash/index.js'),
    path.join(process.cwd(), 'www/src/index.ts'),
    path.join(process.cwd(), 'www/node_modules/miniui-components/index.js')
];

// 模拟 webpack 的 ignored 匹配逻辑
function testIgnored(ignoredPatterns, filePath) {
    const normalizedPath = path.normalize(filePath);
    return ignoredPatterns.some(pattern => {
        if (typeof pattern === 'string') {
            const {minimatch} = require('minimatch');
            return minimatch(normalizedPath, pattern);
        }
        return false;
    });
}

// 测试配置
const ignored = [
    `!${path.join(process.cwd(), 'www')}/**/*`,
    `${path.join(process.cwd(), 'www')}/node_modules/!(miniui-components)/**/*`
];

// 运行测试
testPaths.forEach(testPath => {
    console.log(`测试路径: ${testPath}`);
    console.log(`是否被忽略: ${testIgnored(ignored, testPath)}`);
    console.log('---');
});
